var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (i, e) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, i) {
              t.__proto__ = i;
            }) ||
          function (t, i) {
            for (var e in i)
              Object.prototype.hasOwnProperty.call(i, e) && (t[e] = i[e]);
          })(i, e);
      };
      return function (i, e) {
        function n() {
          this.constructor = i;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        t(i, e),
          (i.prototype =
            null === e
              ? Object.create(e)
              : ((n.prototype = e.prototype), new n()));
      };
    })(),
  NPCDataListDialog = (function (t) {
    function i() {
      var i = t.call(this) || this;
      return (
        (i.isAutoFight = !1),
        WebSocketService.addListener({
          caller: i,
          code: 200,
          method: i.onLoadHomePageInfoData,
        }),
        i
      );
    }
    return (
      __extends(i, t),
      (i.showNpcListDialog = function () {
        null == this.npcListDialog &&
          ((this.npcListDialog = new i()), (this.npcListDialog.zOrder = 1e3)),
          (this.npcListDialog.npcList = []),
          this.npcListDialog.popup(),
          WebSocketService.send({ c: 200 }),
          this.npcListDialog.initNPCList();
      }),
      (i.prototype.initNPCList = function () {
        (this.list_npc_data.selectEnable = !0),
          this.list_npc_data.on(Laya.Event.CLICK, this, this.onBaseNavSelect);
      }),
      (i.prototype.onBaseNavSelect = function (t) {
        if ("" != t.target.name) {
          if (
            ((this.npcObj = this.list_npc_data.selectedItem),
            "btn_dialogue" == t.target.name)
          )
            if (1 == this.npcObj.typeId)
              Laya.stage.event("GameMainView", {
                code: "startRequestFight",
                data: this.npcObj,
              });
            else {
              if (2 == this.npcObj.typeId) {
                if (7e3 == this.npcObj.id) {
                  var i = NPCFuBenView.showFuBenNPCView();
                  return i.pos(0, 50), void Laya.stage.addChild(i);
                }
                return void (CommonActivityView.isThisNpc(this.npcObj.id)
                  ? CommonActivityView.open(this.npcObj.id)
                  : AddSkillCountView.isThisNpc(this.npcObj.id)
                  ? AddSkillCountView.open()
                  : CommunicateDialog.showCommunicationDialog(this.npcObj));
              }
              if (3 == this.npcObj.typeId)
                return void CommunicateDialog.showCommunicationDialog(
                  this.npcObj
                );
            }
          else NPCDetailDialog.showNPCDialog(this.npcObj);
          Laya.timer.once(2e3, this.list_npc_data, function () {
            this.selectedIndex > -1 && (this.selectedIndex = -1);
          });
        }
      }),
      (i.prototype.onLoadHomePageInfoData = function (t) {
        var i = [],
          e = t.npclist;
        e.length > 0 && (this.list_npc_data.visible = !0);
        for (var n, o = "", s = 0; s < e.length; s++)
          (n = {
            id: e[s].id,
            name: e[s].name,
            typeId: e[s].typeId,
            baseNavLabel: { text: e[s].name },
          }),
            i.push(n),
            "副本使者" == e[s].name &&
              ((Global.isFuBen = !0), (o = "副本使者"));
        (this.list_npc_data.visible = "副本使者" != o),
          (this.list_npc_data.array = i),
          (this.npcList = []);
        for (s = 0; s < t.npclist.length; s++) {
          var a = t.npclist[s];
          1 == a.typeId && this.npcList.push(a);
        }
      }),
      i
    );
  })(ui.NPCDialog.NPCDataListDialogUI);
